/* 
 * File:   Database.cpp
 * Author: bd
 * 
 * Created on March 28, 2011, 2:18 PM
 */

#include "Database.hpp"
#include <iostream>

Database::Database(const std::string& connStr, bool connect_now) :
connStr_(connStr)
{
    if (connect_now == true)
        connect();
}

Database::~Database()
{
    session_.close();
}

void Database::connect()
{
    if (connected_ == false)
    {
        session_.open(connStr_);
        connected_ = true;
    }
}

soci::session& Database::session()
{
    return session_;
}

std::string Database::connStr() const
{
    return connStr_;
}